<template>
	<view class="user-chat-item">
		<view v-if="item.gstime" class="user-chat-date m-f-jcc">{{item.gstime}}</view>
		<view class="user-chat-list m-f" :class="{'user-chat-me':item.isme}">
			<image v-if="!item.isme" class="list-img" :src="item.userpic" mode="aspectFill" lazy-load></image>
			<view class="user-chat-list-body">
				<!-- 文字 -->
				<text v-if="item.type == 'text'">{{item.data}}</text>
				<!-- 图片 -->
				<image v-if="item.type == 'img'" class="body-img" :src="item.data" mode="widthFix" lazy-load></image>
			</view>
			<image v-if="item.isme" class="list-img" :src="item.userpic" mode="aspectFill" lazy-load></image>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			item: {
				type: Object
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user-chat-date {
		font-size: 24rpx;
		padding: 50rpx 0;
		color: #a2a2a2;
	}
	.user-chat-list {
		padding: 20rpx 20rpx;
		.list-img {
			width: 100rpx;
			height: 100rpx;
			border-radius: 100%;
			flex-shrink: 0;
		}
		.user-chat-list-body {
			position: relative;
			background: #F4F4F4;
			padding: 25rpx;
			margin-left: 20rpx;
			border-radius: 20rpx;
			margin-right: 100rpx;
			&:after {
				position: absolute;
				left: -30rpx;
				right: 0;
				top: 30rpx;
				content: '';
				width: 0;
				height: 0;
				border: 16rpx solid #F4F4F4;
				border-color: transparent #F4F4F4 transparent transparent;
			}
			.body-img {
				max-width: 150rpx;
				min-height: 200rpx;
			}
		}
	}
	.user-chat-me {
		justify-content: flex-end;
		.user-chat-list-body {
			margin-right: 20rpx;
			margin-left: 100rpx;
			&:after {
				left: auto;
				right: -30rpx;
				border-color: transparent transparent transparent #F4F4F4;
			}
		}
	}
</style>
